package com.example.yrdev.ordering_system.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.yrdev.ordering_system.Model.Good;
import com.example.yrdev.ordering_system.R;

import java.util.ArrayList;

/**
 * Created by luke on 17/11/2016.
 */

public class GoodPaymentAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private ArrayList<Good> payGoodList;

    public GoodPaymentAdapter(Context context, ArrayList<Good> payGoodList){
        inflater= LayoutInflater.from(context);
        this.payGoodList=payGoodList;


    }
    @Override
    public Good getItem(int position) {
        return payGoodList.get(position);

    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public int getCount() {
        return payGoodList.size();

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView==null){
            convertView=inflater.inflate(R.layout.payment_activity_row,null);

        }
        Good respGood=getItem(position);

        TextView goodCode=(TextView)convertView.findViewById(R.id.goods_code);
        TextView goodName=(TextView)convertView.findViewById(R.id.goods_name);
        TextView goodAmount=(TextView)convertView.findViewById(R.id.goods_amount);
        TextView totPrice=(TextView)convertView.findViewById(R.id.goods_retail_price);

        goodCode.setText(respGood.getId());
        goodName.setText(respGood.getName());

        goodAmount.setText(String.valueOf(respGood.getPurchaseCount()));
        totPrice.setText(respGood.getTotalPrice());

        return convertView;

    }
}
